<template>
  <div id="tool-box">
    <h3>贷款计算器</h3>
    <ul class="toolbox">
      <li v-for="(item, index) in boxlist" :key="index" @click="tool(item.name)">
        <div><img :src="item.iconImageUrl" /></div>
        <div>{{item.name}}</div>
      </li>
      <p class="clear"></p>
    </ul>
  </div>
</template>
<script>
import { Card } from 'vux'
import api from '../api'
export default {
  data () {
    return {
      boxlist: []
    }
  },
  components: {
    Card
  },
  created () {
    window.document.title = '工具箱'
    api.toolbox().then(res => {
      console.log(res)
      this.boxlist = res.data.list
    })
  },
  methods: {
    tool (val) {
      if (val === '车贷计算器') {
        window.location.href = '/tool/carloan?shareParam=share'
      }
      if (val === '房贷计算器') {
        window.location.href = '/tool/houseloan?shareParam=share'
      }
      if (val === '理财计算器') {
        window.location.href = '/tool/financecount?shareParam=share'
      }
      if (val === '身价计算器') {
        window.location.href = '/tool/personcount?shareParam=share'
      }
      if (val === '公积金查询') {
        window.location.href = '/tool/accumulation?shareParam=share'
      }
      if (val === '信用报告查询') {
        window.location.href = '/tool/creditreport?shareParam=share'
      }
      if (val === '等额本金') {
        window.location.href = '/tool/averagecapital?shareParam=share'
      }
      if (val === '等额本息') {
        window.location.href = '/tool/fixedpayment?shareParam=share'
      }
    }
  }
}
</script>

